package com.fr.data.core.define;

import com.fr.base.XMLable;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.core.Compare;
import com.fr.report.cellElement.Formula;
import com.fr.report.core.ReportCoreConstants;
import java.io.Serializable;

public class LineJoinCondition
  implements Cloneable, Serializable, XMLable
{
  public static int Default = 0;
  public static int Formula = 1;
  private int type = Default;
  private Formula formula;
  private int join;
  private SelectionColumn selectionColumn;
  private Compare condition;

  public LineJoinCondition()
  {
  }

  public LineJoinCondition(int paramInt1, SelectionColumn paramSelectionColumn, int paramInt2, Object paramObject)
  {
    this.join = paramInt1;
    this.selectionColumn = paramSelectionColumn;
    this.condition = new Compare(paramInt2, paramObject);
    this.type = Default;
  }

  public LineJoinCondition(int paramInt, Formula paramFormula)
  {
    this.join = paramInt;
    this.formula = paramFormula;
    this.type = Formula;
  }

  public int getJoin()
  {
    return this.join;
  }

  public SelectionColumn getSelectionColumn()
  {
    return this.selectionColumn;
  }

  public void setSelectionColumn(SelectionColumn paramSelectionColumn)
  {
    this.selectionColumn = paramSelectionColumn;
  }

  public Compare getCondition()
  {
    return this.condition;
  }

  public Formula getFormula()
  {
    return this.formula;
  }

  public int getType()
  {
    return this.type;
  }

  public void setValue(Object paramObject)
  {
    this.condition.setValue(paramObject);
  }

  public String toString()
  {
    return this.selectionColumn.getName() + " " + ReportCoreConstants.conditionToString(getCondition());
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      String str1;
      if ((str1 = paramXMLableReader.getAttr("join")) != null)
        this.join = Integer.parseInt(str1);
      if ((str1 = paramXMLableReader.getAttr("type")) != null)
        this.type = Integer.parseInt(str1);
    }
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("SelectionColumn"))
      {
        this.selectionColumn = new SelectionColumn();
        paramXMLableReader.readXMLObject(this.selectionColumn);
      }
      else if (("Compare".equals(str2)) || (str2.equals("Condition")))
      {
        this.condition = new Compare(0, "");
        paramXMLableReader.readXMLObject(this.condition);
      }
      else if (str2.equals("Formula"))
      {
        this.formula = new Formula(paramXMLableReader.getElementValue());
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("LineJoinCondition").attr("join", getJoin()).attr("type", getType());
    if (getSelectionColumn() != null)
      getSelectionColumn().writeXML(paramXMLPrintWriter);
    if (getCondition() != null)
      getCondition().writeXML(paramXMLPrintWriter);
    if (getFormula() != null)
      paramXMLPrintWriter.startTAG("Formula").textNode(getFormula().getContent()).end();
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    LineJoinCondition localLineJoinCondition = (LineJoinCondition)super.clone();
    localLineJoinCondition.type = this.type;
    if (this.selectionColumn != null)
      localLineJoinCondition.selectionColumn = ((SelectionColumn)this.selectionColumn.clone());
    if (this.condition != null)
      localLineJoinCondition.condition = ((Compare)this.condition.clone());
    if (this.formula != null)
      localLineJoinCondition.formula = ((Formula)this.formula.clone());
    return localLineJoinCondition;
  }

  public boolean equals(Object paramObject)
  {
    if (this == paramObject)
      return true;
    if (paramObject == null)
      return false;
    if (super.getClass() != paramObject.getClass())
      return false;
    LineJoinCondition localLineJoinCondition = (LineJoinCondition)paramObject;
    return ((this.join == localLineJoinCondition.getJoin()) && (getType() == localLineJoinCondition.getType()) && (getSelectionColumn().equals(localLineJoinCondition.getSelectionColumn())) && (getCondition().equals(localLineJoinCondition.getCondition())));
  }
}